package gov.pbc.nn.kjgl.jfcr.handler;

import gov.pbc.nn.kjgl.entity.ComputerRoomApplyEntry;
import gov.pbc.nn.kjgl.jfcr.dao.ApplyEntryDao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.bstek.uflo.env.Context;
import com.bstek.uflo.model.ProcessInstance;
import com.bstek.uflo.model.task.Task;
import com.bstek.uflo.process.listener.TaskListener;
import com.bstek.uflo.process.node.TaskNode;

@Component("jfglbl.TaskName")
public class JfglblTaskName implements TaskListener {

	@Autowired
	private ApplyEntryDao applyEntryDao;

	@Override
	public boolean beforeTaskCreate(Context arg0, ProcessInstance arg1, TaskNode arg2) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void onTaskComplete(Context arg0, Task arg1) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onTaskCreate(Context context, Task task) {
		String businessId = task.getBusinessId();
		ComputerRoomApplyEntry computerRoomApplyEntry = this.applyEntryDao.get(businessId, ComputerRoomApplyEntry.class);
		task.setTaskName("机房管理员保留【"+computerRoomApplyEntry.getTitle()+"】");
		context.getSession().saveOrUpdate(task);
	}

}
